package com.banshuibao.bsb_android.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.widget.TextView;

import com.banshuibao.bsb_android.R;
import com.banshuibao.bsb_android.model.OneModel;
import com.banshuibao.bsb_android.util.PriceUtil;
import com.banshuibao.bsb_android.util.TimeUtil;

import java.util.List;

/**
 * Created by liangzetaoliang on 2017/12/28.
 */

public class OneAdapter extends MineBaseAdapter<OneModel.DataBean> {

    private Context context;

    public OneAdapter(Context context, List<OneModel.DataBean> data, int layoutResId) {
        super(context, data, layoutResId);
        this.context = context;
    }

    @Override
    protected void bindData(ViewHolder holder, OneModel.DataBean item) {
        TextView content = (TextView) holder.getView(R.id.item_tab_content);
        TextView date = (TextView) holder.getView(R.id.item_tab_date);
        TextView status = (TextView) holder.getView(R.id.item_tab_status);
        TextView money = (TextView) holder.getView(R.id.item_tab_money);

        if (item != null) {
            String question = item.getQuestion();
            String status1 = item.getStatus();

            content.setText(question);
            String time = null;
            if (item.getCreateDate() != 0) {
                time = TimeUtil.format(item.getCreateDate());
            } else {
                time = "";
            }
            date.setText(time);
            money.setText("¥" + PriceUtil.FormatDecimal(item.getPrice()));
            if (!TextUtils.isEmpty(status1) && status1.equals("0") || status1.equals("2") || status1.equals("4")) {
                status.setText("未回答");
            } else if (!TextUtils.isEmpty(status1) && status1.equals("1") || status1.equals("3") || status1.equals("5")) {
                status.setText("已回答");
            } else if (!TextUtils.isEmpty(status1) && status1.equals("7")) {
                status.setText("退款中");
            } else if (!TextUtils.isEmpty(status1) && status1.equals("8")) {
                status.setText("已退款");
            } else if (!TextUtils.isEmpty(status1) && status1.equals("6")) {
                status.setText("已过期");
            } else if (!TextUtils.isEmpty(status1) && status1.equals("9")) {
                status.setText("退款异常");
            }
        }
    }
}
